package com.atguigu.day14.test04;

import java.util.Scanner;

/**
 * @author fenge
 */
public class Test04 {
    public static void main(String[] args) {
        System.out.println("请输入源字符串:");
        Scanner s = new Scanner(System.in);
        String str1 = s.next();
//        String str1 = "java woaijava,i like jajavava i enjoy java";
        System.out.println("请输入要删除的字符串：");
        String subStr = s.next();
//        String subStr = "ja";
        System.out.print("源字符串中总共包含：");
        int count=0;
        String str = str1;
//        System.out.println(str.indexOf(subStr));
        do {
            if (str.indexOf(subStr)>=0){
                count++;
                str1 = str1.replace(subStr,"");
                str=str.substring(str.indexOf(subStr)+subStr.length());
            }
        }while (str.length()>subStr.length());
        System.out.println(count+" 个 "+subStr +",");
        System.out.print("删除"+subStr+"后的字符串为："+str1);
    }
}
